package com.checkoutcheckins.client.panels;

import com.checkoutcheckins.client.data.foursquare.FoursquareUser;
import com.checkoutcheckins.client.data.foursquare.Venue;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MayorshipsPanel extends VerticalPanel {

	public MayorshipsPanel(FoursquareUser fsUser) {
		super();
		init(fsUser);
	}

	private void init(FoursquareUser fsUser) {

		this.setStyleName("padding");

		VerticalPanel mayorTable = new VerticalPanel();
		mayorTable.addStyleName("onefifty");

		if (fsUser.getMayor() != null) {

			for (Venue venue : fsUser.getMayor()) {
				Anchor venueLink = new Anchor("- " + venue.getName(),
						"http://www.foursquare.com/venue/" + venue.getId(),
						"_blank");

				this.add(venueLink);
			}
			this.add(mayorTable);
		}
		else
		{
			this.add(new HTML("You have no Mayorships at this time!  Keep at it!"));
		}
	}

}
